home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 1.toast / Sample Code / Human Interface Toolbox / Live Scroll / AppleEvents.c next >
Encoding:
Text File  |  2000-09-28  |  2.8 KB  |  121 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        AppleEvents.c
  3.  
  4.     Contains:    Handlers for the 4 "required" events
  5.  
  6.     Written by: Chris White    
  7.  
  8.     Copyright:    Copyright © 1996-1999 by Apple Computer, Inc., All Rights Reserved.
  9.  
  10.                 You may incorporate this Apple sample source code into your program(s) without
  11.                 restriction. This Apple sample source code has been provided "AS IS" and the
  12.                 responsibility for its operation is yours. You are not permitted to redistribute
  13.                 this Apple sample source code as "Apple sample source code" after having made
  14.                 changes. If you're going to re-distribute the source, we require that you make
  15.                 it clear in the source that the code was descended from Apple sample source
  16.                 code, but that you've made changes.
  17.  
  18.     Change History (most recent first):
  19.                 8/6/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  20.                 
  21.  
  22. */
  23.  
  24.  
  25. // System Includes
  26.  
  27. #ifndef __APPLEEVENTS__
  28.     #include <AppleEvents.h>
  29. #endif
  30.  
  31.  
  32.  
  33.  
  34. // Application includes
  35.  
  36. #ifndef __BAREBONES__
  37.     #include "BareBones.h"
  38. #endif
  39.  
  40. #ifndef __PROTOTYPES__
  41.     #include "Prototypes.h"
  42. #endif
  43.  
  44.  
  45.  
  46.  
  47.  
  48. // Static Prototypes
  49. static pascal OSErr HandleOapp ( AEDescList* aevt, AEDescList* reply, long refCon );
  50. static pascal OSErr HandleQuit ( AEDescList* aevt, AEDescList* reply, long refCon );
  51. static pascal OSErr HandleOdoc ( AEDescList* aevt, AEDescList* reply, long refCon );
  52. static pascal OSErr HandlePdoc ( AEDescList* aevt, AEDescList* reply, long refCon );
  53.  
  54.  
  55.  
  56. #pragma segment Initialize
  57.  
  58. OSErr InstallAppleEventHandlers ( void )
  59. {
  60.     OSErr    theErr;
  61.     
  62.     
  63.     theErr = AEInstallEventHandler ( kCoreEventClass, kAEOpenApplication, NewAEEventHandlerProc ( HandleOapp ), 0, false );
  64.     if ( theErr )    goto CleanupAndBail;
  65.  
  66.     theErr = AEInstallEventHandler ( kCoreEventClass, kAEOpenDocuments, NewAEEventHandlerProc ( HandleOdoc ), 0, false );
  67.     if ( theErr )    goto CleanupAndBail;
  68.  
  69.     theErr = AEInstallEventHandler ( kCoreEventClass, kAEPrintDocuments, NewAEEventHandlerProc ( HandlePdoc ), 0, false );
  70.     if ( theErr )    goto CleanupAndBail;
  71.  
  72.     theErr = AEInstallEventHandler ( kCoreEventClass, kAEQuitApplication, NewAEEventHandlerProc ( HandleQuit ), 0, false );
  73.     if ( theErr )    goto CleanupAndBail;
  74.     
  75.     
  76. CleanupAndBail:
  77.  
  78.     return theErr;
  79.     
  80. }    // InstallAppleEventHandlers
  81.  
  82.  
  83.  
  84. #pragma segment Core
  85.  
  86. static pascal OSErr HandleOapp ( AEDescList* aevt, AEDescList* reply, long refCon )
  87. {
  88.     #pragma unused(aevt,reply,refCon)
  89.     return errAEEventNotHandled;
  90. }
  91.  
  92.  
  93.  
  94. static pascal OSErr HandleOdoc ( AEDescList* aevt, AEDescList* reply, long refCon )
  95. {
  96.     #pragma unused(aevt,reply,refCon)
  97.     return errAEEventNotHandled;
  98. }
  99.  
  100.  
  101.  
  102. static pascal OSErr HandlePdoc ( AEDescList* aevt, AEDescList* reply, long refCon )
  103. {
  104.     #pragma unused(aevt,reply,refCon)
  105.     return errAEEventNotHandled;
  106. }
  107.  
  108.  
  109.  
  110. static pascal OSErr HandleQuit ( AEDescList* aevt, AEDescList* reply, long refCon )
  111. {
  112.     #pragma unused(aevt,reply,refCon)
  113.     gQuit = true;
  114.     
  115.     return noErr;
  116. }
  117.  
  118.  
  119.  
  120.  
  121.